/*-----------------------------------------------------------------------------
 * @file hal_delay.c
 * @brief interface for Precise delay with counter
 * @author WLH<wanglehui8357@163.com> Copyright (C) 2021~2099.
 ----------------------------------------------------------------------------*/
#include "hal_delay.h"
#include "hal_hrt.h"
#include "systick.h"

/*-----------------------------------------------------------------------------
 * marcro define
-----------------------------------------------------------------------------*/

/*-----------------------------------------------------------------------------
 * local variable
-----------------------------------------------------------------------------*/

/*-----------------------------------------------------------------------------
 * local functions
-----------------------------------------------------------------------------*/

/*-----------------------------------------------------------------------------
 * public functions
-----------------------------------------------------------------------------*/
void hal_delay_us(U32 us)
{
    uint32_t ts_us = hal_hrt_get_us();
    while ((hal_hrt_elapsed_us(ts_us)) < us)
        ;
}

void hal_delay_ms(U32 ms)
{
    delay_1ms(ms);
}
